package com.serv.util;

public class Result {
	private int code = 0;
	private String msg = "";
	private int count = 0;
	private Object data;
	
	public Result(){
		
	}
	
	public Result(String msg){
		this.msg = msg;
	}
	
	public Result(int code,String msg){
		this.code = code;
		this.msg = msg;
	}
	
	public Result(int code,String msg, Object data){
		this.code = code;
		this.msg = msg;
		this.data = data;
	}
	
	public static Result success(){
		return Result.success("操作成功");
	}
	
	public static Result success(String msg){
		return new Result(0,msg);
	}
	
	public static Result success(String msg,Object data){
		Result result = Result.success(msg);
		result.setData(data);
		return result;
	}
	
	public static Result data(Object data,int count){
		Result result = Result.success("查询成功");
		result.setData(data);
		result.setCount(count);
		return result;
	}
	
	public static Result error(){
		return Result.error("操作失败");
	}
	
	public static Result error(String msg){
		return new Result(1,msg);
	}
	
	public int getCode() {
		return code;
	}
	public void setCode(int code) {
		this.code = code;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}

	public void setMessage(String message) {
		this.msg = message;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public Object getData() {
		return data;
	}
	public void setData(Object data) {
		this.data = data;
	}
}
